/*
 * Utils.h
 *
 *  Created on: 18 Jun 2011
 *      Author: allan
 */

#ifndef UTILS_H_
#define UTILS_H_

// C++ includes
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <set>
#include <string>
#include <vector>
using namespace std;

// Boost includes
#include <boost/foreach.hpp>

//==================================================//
// Typedefs
//==================================================//
typedef unsigned
uint;

typedef uint
Index;

typedef string
String;

typedef vector<double>
DoubleVector;

typedef vector<Index>
IndexVector;

typedef vector<String>
StringVector;

typedef set<String>
StringSet;

struct ReactionInfo
{
	/// The formula of the reactant in the reaction
	String reactant;
	
	/// The formulas of the products in the reaction 
	StringVector products;
	
	/// The stoichiometries of the products in the reaction     
	DoubleVector stoichiometries;
	
	/// The equilibrium constants of the reaction over a set of temperature points
	DoubleVector logKi;
	
	/// The temperature points where the equilibrium constants are interpolated       
	DoubleVector Ti;
};

struct SpeciesInfo
{
	String formula;
	String name;
	double molecularWeight;
	double volumetricWeigth;
	double radius;
	StringVector tags;

	SpeciesInfo() : molecularWeight(0), volumetricWeigth(0), radius(0) {}

	bool 
	HasTag(const String& tag) const { return std::find(tags.begin(), tags.end(), tag) != tags.end(); }
	
	bool 
	HasAnyTag(const StringVector& tags) const { for(uint i = 0; i < tags.size(); ++i) if(HasTag(tags[i])) return true; return false; }
};

//==================================================//
// Functions
//==================================================//
const double 
ElectricalCharge(String speciesName);

const StringVector
SplitLineAndClean(const String& line, const String& tokens);

//==================================================//
// Overloaded Operators
//==================================================//
ostream& operator<<(ostream& out, const StringVector& vec);
ostream& operator<<(ostream& out, const DoubleVector& vec);
ostream& operator<<(ostream& out, const IndexVector&  vec);

#endif /* UTILS_H_ */
